#include <iostream>
#include <string>
#include <errno.h>
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#define PATH "./fifo"
#define MODE 0666
using namespace std;
class Fifo
{
public:
    Fifo(const string &path) : _path(path)
    {
        umask(0000);
        int n = mkfifo(PATH, MODE);
        if (n == 0)
        {
            cout << "fifo success!" << endl;
        }
        else
        {
            cerr << "fifo failed! " << "errno is " << errno << " " << strerror(errno) << endl;
        }
    }
    ~Fifo()
    {
        int n = unlink(PATH);
        if (n == 0)
        {
            cout << "remove file fifo success!" << endl;
        }
        else
        {
            cerr << "remove file fifo failed! " << "errno is " << errno << " " << strerror(errno) << endl;
        }
    }

private:
    string _path;
};